<template>
	<view class="content">
		<view class="nav">
			<uni-nav-bar title="订单详情" backgroundColor="transparent" left-icon="left" @clickLeft="goback">
				<block slot="right">
					
				</block>
			</uni-nav-bar>
		</view>
		
		<view class="status box">
			<view class="title" style="color: #EF4C28;" v-if="data.status==1 && data.return_status <= 1 && data.sfter_sales <= 1">待接单</view>
			<view class="title" style="color: #FFA126;" v-if="data.status==2 && data.return_status <= 1 && data.sfter_sales <= 1">待开始</view>
			<view class="title" style="color: #2E7EFA;" v-if="data.status==3 && data.return_status <= 1 && data.sfter_sales <= 1">进行中</view>
			<view class="title" style="color: #6D6F6F;" v-if="data.status==4 && data.return_status <= 1 && data.sfter_sales <= 1">已完成</view>
			<view class="title" style="color: #6D6F6F;" v-if="data.status==5 && data.return_status <= 1 && data.sfter_sales <= 1">待评价</view>
			<view class="title" style="color: #6D6F6F;" v-if="data.status==6 && data.return_status <= 1 && data.sfter_sales <= 1">已评价</view>
			<view class="title" style="color: #EF4C28;" v-if="data.return_status==2">退款申请中</view>
			<view class="title" style="color: #EF4C28;" v-if="data.return_status==3">商家同意退款/平台待处理</view>
			<view class="title" style="color: #EF4C28;" v-if="data.return_status==4">已退款</view>
			<view class="title" style="color: #EF4C28;" v-if="data.sfter_sales == 2">已投诉</view>
			<view class="title" style="color: #EF4C28;" v-if="data.sfter_sales == 3">投诉已处理</view>
			<view class="time">
				<view>
					<uni-dateformat :date="data.pay_time*1000" format="MM-dd hh:mm"></uni-dateformat>
				</view>
			</view>
		</view>
		
		<view class="people box">
			<image :src="data.technician && data.technician.auth_image"></image>
			<view class="right">
				<view class="name">
					<text>{{data.technician.technician_nickname || data.technician.real_name}}</text>
					<!-- <view class="rate_num">
						评价人数：{{data.technician.high_opinion}}
					</view> -->
				</view>
				<uni-rate :touchable="false" v-model="data.technician.high_opinion / data.technician.opinion * 5 || 5" disabled disabledColor="#EF5233" />
			</view>
		</view>
		
		<view class="date box">
			<view class="title">预约时间</view>
			<view class="time">
				<view>{{data.subscribe_time}}</view>
			</view>
		</view>
		
		<view class="address box">
			<view class="block_address">
				<image src="/static/order/address.png"></image>
				<view class="detail">
					<view class="address_content" @click="onCopy(data.address.city + data.address.district + data.address.address)">
						{{data.address.city}} {{data.address.district}}{{data.address.address}}{{data.address.house_number}}
						<image src="/static/jishi/copy.png"></image>
					</view>
					<view class="phone">
						<text>{{data.address.real_name}}</text>
						<view>{{data.address.mobile}}</view>
						<image src="/static/jishi/copy.png" @click="onCopy(data.address.mobile)"></image>
					</view>
				</view>
			</view>
			<view class="icon">
				<!-- <uni-icons type="forward" size="16" color="#333"></uni-icons> -->
			</view>
		</view>
		
		<view class="prudect box">
			<view class="prudect_detail">
				<view class="shop">
					<image :src="data.service.image" mode="aspectFill"></image>
					<view class="detail">
						<view class="title">{{data.service.title}}</view>
						
						<view class="text">总价:￥{{data.service.price}}</view>
					</view>
				</view>
				<!-- <view class="num">X {{data.service.buy_num}}</view> -->
			</view>
			
			<view class="price">
				实际金额：<text>¥ {{data.price}}</text>
			</view>
			
			<view class="price">
				交通费：<text>¥ {{data.traffic_price}}</text>
			</view>
			
		</view>
		
		<view class="order_sn box" v-if="data.status>=2">
			<view class="text">
				<text>订单编号</text>
				<view>{{data.order_sn}}</view>
			</view>
			<view class="text">
				<text>下单时间</text>
				<view>
					<uni-dateformat :date="data.pay_time*1000" format="yyyy/MM/dd hh:mm"></uni-dateformat>
				</view>
			</view>
			<view class="text" v-if="data.remark">
				<text>用户备注</text>
				<view>
					{{data.remark}}
				</view>
			</view>
		</view>
		
		<view class="btn" v-if="(data.status==2 && data.return_status <= 1 && data.jiedan_time <= 0) || (data.status==2 && data.return_status && data.jiedan_time > 0) || (data.status==4 && data.return_status && data.jiedan_time > 0)">
			<!-- 待接单 -->
			<view class="btn_box" v-if="data.status==2 && data.return_status <= 1 && data.jiedan_time <= 0" @click="getOrder">
				<view class="btn_orange">立即接单</view>
			</view>
			<!-- 待服务 -->
		<!-- 	<view class="btn_box" v-if="data.status==2 && data.return_status && data.jiedan_time > 0" @click="scanOrderQr">
				<view class="btn_orange" style="background: #FFA126;align-items: center;display: flex;padding: 0 250rpx;"><uni-icons type="scan" :size="20" color="#FFF"></uni-icons><text>扫码开始</text></view>
			</view> -->
			<!-- 服务中 -->
			<!-- <view class="btn_box" v-if="data.status==3 && data.return_status && data.jiedan_time > 0" @click="onComplant">
				<view class="btn_orange" style="background: #2E7EFA;align-items: center;display: flex;padding: 0 250rpx;">
					订单完成
				</view>
			</view> -->
		</view>
		
		
		<u-modal v-model="show" @confirm="confirm" 
		ref="uModal" :async-close="false" title="确认接单" 
		content="接单后进行扫码，订单开始，同时开始打开手机录音，保证客户与技师的身体以及财务安全！"
		show-cancel-button
		:title-style="{
			'background':'#EAF2FE',
			color:'#2E7EFA',
			'font-weight':600,
			padding:'30rpx 0'
		}"
		:confirm-style="{
			'background':'#EAF2FE',
		}"
		></u-modal>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:'',
				
				auth:'',
				
				show:false,
			}
		},
		methods: {
			onCopy(e){
				uni.setClipboardData({
					data:e,
					success:()=> {
						this.$util.msg('已复制到剪切板')
					}
				})
			},
			goback(){ uni.navigateBack() },
			onCode(){
				this.$refs.code.open('center')
			},
			closeCode(){
				this.$refs.code.close()
			},
			scanOrderQr(){
				this.show = true
			},
			onComplant(){
				this.request.httpTokenRequest({
					url: "/technician.order/setOrderStatus",
					method: "post"
				}, {
					order_id:this.data.id,
					status:4
				}).then(res => {
					if (res.code == 0) {
						this.$util.modal(res.msg)
					} else {
						this.$util.msg(res.msg)
					}
				}, error => {})
			},
			confirm(){
				this.$util.scanCode(res=>{
					this.request.httpTokenRequest({
						url: "technician.order/scanOrderQr",
						method: "post"
					}, {
						order_id:res.result
					}).then(data => {
						this.show = false
						if (data.code == 0) {
							uni.reLaunch({
								url:'/technician/recorderManager/recorderManager?id=' + res.result
							})
						} else {
							this.$util.msg(data.msg)
						}
					}, error => {})
				})
			},
			getOrder(){
				this.request.httpTokenRequest({
					url: "/technician.order/receivingOrders",
					method: "post"
				}, {
					order_id:this.data.id
				}).then(res => {
					if (res.code == 0) {
						this.data.status = 2
						this.$util.modal(res.msg)
					} else {
						this.$util.msg(res.msg)
					}
				}, error => {})
			},
		},
		onLoad(option) {
			this.data = JSON.parse(option.data)
			this.auth = uni.getStorageSync('authInfo')
		},
		
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: calc(var(--status-bar-height) + 44px) 30rpx 150rpx;
	}
	.box {
		padding: 30rpx;
		margin-bottom: 30rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
	}
	.nav {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		background: #F5F7F8;
		z-index: 99;
		padding-top: var(--status-bar-height);
	}
	.location {
		width: 153rpx;
		height: 64rpx;
		background: rgba(255, 255, 255, 0.7);
		border-radius: 32rpx;
		opacity: 0.71;
		backdrop-filter: blur(10px);
		line-height: 64rpx;
		display: flex;
		align-items: center;
		padding: 0 27rpx;
		box-sizing: border-box;
	
		image {
			width: 26rpx;
			height: 26rpx;
			margin-left: 13rpx;
		}
	
		view {
			font-size: 28rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			color: #000000;
		}
	}

	.status {
		.title {
			font-size: 30rpx;
			font-weight: 600;
			color: #CB2C25;
			line-height: 42rpx;
		}
		.time {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 12rpx;
			view {
				font-size: 26rpx;
				color: #1C1D1E;
				line-height: 37rpx;
			}
			text {
				font-size: 26rpx;
				font-weight: 600;
				color: #CB2C25;
				line-height: 37rpx;
			}
		}
	}

	.people {
		padding: 30rpx 30rpx 20rpx;
		display: flex;
		align-items: center;
		image {
			width: 70rpx;
			height: 70rpx;
			border-radius: 50%;
			margin-right: 10rpx;
		}
		.right {
			flex:1;
			.name {
				display: flex;
				align-items: center;
				text {
					font-size: 26rpx;
					padding-left: 6rpx;
					font-weight: 600;
					color: #333333;
					line-height: 37rpx;
				}
				view {
					font-size: 26rpx;
					line-height: 37rpx;
					color: #EF5233;
				}
			}
		}
	}

	.date {
		display: flex;
		align-items: center;
		justify-content: space-between;
		.title {
			font-size: 28rpx;
			color: #151616;
			line-height: 40rpx;
		}
		.time {
			display: flex;
			align-items: center;
			view {
				font-size: 26rpx;
				font-weight: 600;
				color: #EC473E;
				line-height: 37rpx;
				margin: 0 12rpx 0 0;
			}
			.tag {
				width: 49rpx;
				height: 26rpx;
				background: #EC473E;
				border-radius: 4rpx;
				font-size: 20rpx;
				color: #FFFFFF;
				line-height: 26rpx;
				text-align: center;
				margin: 0 12rpx 0 0;
			}
		}
	}

	.address {
		display: flex;
		justify-content: space-between;
		.icon {
			width: 20px;
			width: 20px;
		}
		.block_address {
			display: flex;
			image {
				width: 32rpx;
				height: 30rpx;
				margin-right: 10rpx;
			}
			.address_content {
				// display: flex;
				font-size: 30rpx;
				font-weight: 600;
				color: #151616;
				line-height: 42rpx;
				image {
					margin-left: 10rpx;
					width: 30rpx;
					height: 30rpx;
				}
			}
			.phone {
				display: flex;
				margin-top: 20rpx;
				text {
					font-size: 26rpx;
					color: #151616;
					line-height: 37rpx;
					margin-right: 20rpx;
				}
				view {
					font-size: 26rpx;
					color: #151616;
					line-height: 37rpx;
				}
				image {
					margin-left: 10rpx;
					width: 30rpx;
					height: 30rpx;
				}
			}
		}
	}
	
	.prudect {
		.prudect_detail {
			display: flex;
			align-items: flex-end;
			padding-bottom: 30rpx;
			border-bottom: 1rpx solid #E9E9E9;
			.shop {
				display: flex;
				flex: 1;
				image {
					width: 142rpx;
					height: 190rpx;
					margin-right: 23rpx;
				}
			
				.detail {
					flex: 1;
			
					.title {
						font-size: 28rpx;
						color: #656667;
						line-height: 40rpx;
					}
			
					.text {
						font-size: 24rpx;
						color: #656667;
						line-height: 33rpx;
						margin-top: 10rpx;
					}
				}
			}
			.num {
				font-size: 24rpx;
				color: #656667;
				line-height: 33rpx;
			}
		}
		.coupon {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx 0;
			border-bottom: 1rpx solid #E9E9E9;
			.title {
				font-size: 30rpx;
				color: #0F0807;
				line-height: 42rpx;
			}
			.text {
				display: flex;
				align-items: center;
				text {
					font-size: 26rpx;
					font-weight: 600;
					color: #EF5233;
					line-height: 37rpx;
					margin-right: 10rpx;
				}
			}
		}
		.price {
			font-size: 24rpx;
			color: #333333;
			line-height: 33rpx;
			text-align: right;
			padding-top: 35rpx;
			text {
				font-size: 30rpx;
				color: #EF5233;
				line-height: 33rpx;
			}
		}
	}

	.order_sn {
		.text {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 28rpx;
			text {
				font-size: 30rpx;
				color: #0F0807;
				line-height: 42rpx;
			}
			view {
				font-size: 30rpx;
				color: #0F0807;
				line-height: 42rpx;
			}
		}
	}
	
	.code {
		display: flex;
		align-items: center;
		flex-direction: column;
		box-sizing: border-box;
		background: url(https://qiniu-cdn.maeiyun.com/imgs/order/service_code.png) 0 0 no-repeat;
		background-size: 100%;
		height: 569rpx;
		width: 680rpx;
		view {
			font-size: 34rpx;
			font-weight: 600;
			color: #691100;
			line-height: 40rpx;
		}
		image {
			width: 252rpx;
			height: 252rpx;
			margin: 100rpx 0 31rpx;
		}
		text {
			font-size: 24rpx;
			color: #A9A9A9;
			line-height: 40rpx;
		}
		
	}
	.block {
		display: flex;
		align-items: center;
		flex-direction: column;
	}
	
	.btn {
		width: 100vw;
		height: 120rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		.btn_box {
			width: 100%;
			height: 100%;
			display: flex;
			align-items: center;
			justify-content: space-around;
			view {
				width: 689rpx;
				height: 88rpx;
				border-radius: 44rpx;
				line-height: 88rpx;
				text-align: center;
				font-size: 34rpx;
				margin: 0 15rpx;
			}
			.btn_orange {
				color: #FFFFFF;
				background: #EF5233;
				// border: 1rpx solid #EF5233;
			}
			.btn_black {
				border: 1rpx solid #C6C6C6;
				color: #A8A8A8;
			}
			.btn_yellow {
				border: 1rpx solid #FFA126;
				color: #FFA126;
			}
		}
	}

</style>
